import instance from '@/api/request'

// 获取所有的文章
export const getTableData = ()=>{
  return instance.get('/article/getArticleList')
}

// 添加文章接口
export const addArticleNew = (data:any)=>{
  return instance.post('/article/addArticle',data)
}

// 删除文章接口
export const deleteArticle =(id:any)=>{
  return instance.delete(`/article/delArticleById/${id}`)
}

// 根据id获取指定文章
export const getArticleById = (id:any)=>{
  return instance.get(`/article/getArticleById?id=${id}`)
}

// 更新文章接口
export const updateArticle = (id:any,data:any)=>{
  return instance.patch(`/article/updateArticle/${id}`,data)
}

// 根据文章标题实现搜索接口
export const getArticleByTitle = (words:string)=>{
  return instance.get(`/article/searchByTitle?words=${words}`)
}


// 根据日期时间搜索文章
export const getArticleByDateTime = (date:any)=>{
  return instance.get(`/article/searchByDate?start=${date[0]}&end=${date[1]}`)
}


// 根据状态搜索文章
export const getArticleByState = (status:any)=>{
  return instance.get(`/article/searchByStatus?status=${status}`)
}

// 获取文章详情
export const getArticleDetail = (id:any)=>{
  return instance.get(`/article/getArticleDetail?id=${id}`)
}